﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DotNetDal.Core.StructureAttributes
{
    /// <summary>
    /// Used to mark a class field as a database field.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class FieldAttribute : Attribute
    {
        /// <summary>
        /// Indicates that this field is the PK field for the table in the database
        /// </summary>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// Determines if this type can be set to null; default is false
        /// </summary>
        public bool IsNullable { get; set; }

        /// <summary>
        /// Indicates that this field should be marked as an identity for SQL Server to auto-increment
        /// </summary>
        public bool IsAutoNumber { get; set; }

        /// <summary>
        /// Stores the SqlDbType of the field
        /// </summary>
        public DbType DbType { get; set; }

        /// <summary>
        /// Set the maximum length of a text field
        /// </summary>
        public int DataLength { get; set; }

        /// <summary>
        /// Number of digits to the right of the . to store (applies to Decimal only)
        /// </summary>
        public int DecimalDigits { get; set; }

        /// <summary>
        /// The default value for this field (can be an expression). From the SQL Server documentation, default is
        /// "a literal value, a NULL, or a system function used as the default column value." Be sure to quote string values.
        /// </summary>
        public string Default { get; set; }
    }
}
